"""
    Controller for final work mark.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController

class FinalWorkMarkController(LookupController, CRUDController):
    model_object = model.FinalWorkMark
    lookup_columns = [
        TableCol(name='topic', caption=_('Topic')),
        TableCol(name='date', caption=_('Date')),
        TableCol(name='student', caption=_('Student')),
        TableCol(name='student_groups', caption=_('Groups')),
        TableCol(name='hours', caption=_('Hours')),
        TableCol(name='mark_type', caption=_('Mark type')),
        TableCol(name='protocol_number', caption=_('Protocol #')),
        TableCol(name='comment', caption=_('Comment'), hidden=True),
        ]

    edit_fields = ['date', 'topicID', 'hours', 'studentID', 'markTypeID', 'protocolNumber', 'comment']
    view_fields = edit_fields + ['ownerID']

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('final_work_mark_lookup'),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = FinalWorkMarkController()
